# Maintainer: David Runge <dave@sleepmap.de>
# Contributor: speps <speps at aur dot archlinux dot org>
# Contributor: Christoph Zeiler <rabyte*gmail>
# Contributor: Tom K <tomk@runbox.com>
# Contributor: Shinlun Hsieh <yngwiexx@yahoo.com.tw>
# Contributor: Philipp Überbacher <murks at lavabit dot com>

pkgname=clxclient
pkgver=3.9.2
pkgrel=4
pkgdesc="C++ wrapper library around the X Window System API"
arch=('loong64' 'x86_64')
url="https://kokkinizita.linuxaudio.org/linuxaudio/"
license=('LGPL2.1')
depends=('gcc-libs' 'glibc' 'libx11' 'libxft')
makedepends=('clthreads')
provides=('libclxclient.so')
source=("https://kokkinizita.linuxaudio.org/linuxaudio/downloads/${pkgname}-${pkgver}.tar.bz2")
sha512sums=('38c2782e58df24c2dfcb936fc9cfe4d44016055fb1aa52ef8e789bf8ec327f45f2f7a91f18012e4b0c6f253f6f10329d6d1e9fc341017ace3f2b6fa050592049')

prepare() {
  cd "$pkgname-$pkgver"
  # removing optimization
  # call ldconfig in local context
  sed -e '/native/d' \
      -e 's/ldconfig/& -N $(DESTDIR)\/$(LIBDIR)/' \
      -i source/Makefile
  # fix global header include
  sed -e 's/<clxclient.h>/\"clxclient.h\"/' -i source/enumip.cc
}

build() {
  cd "${pkgname}-${pkgver}"
  make -C source
}

package(){
  cd "${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}/" PREFIX='/usr' LIBDIR='/usr/lib' -C source install
  install -vDm 644 AUTHORS -t "${pkgdir}/usr/share/doc/${pkgname}"
}
